# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>
# Contributor: PepeSmith
# Contributor: Aron Asor <aronasorman at gmail.com>
# Contributor: Chris Brannon <chris@the-brannons.com>
# Contributor: Douglas Soares de Andrade <dsa@aur.archlinux.org>

pkgname=ipython
pkgver=8.17.2
pkgrel=1
pkgdesc='Enhanced Interactive Python shell'
arch=('any')
url=https://ipython.org
license=('BSD')
depends=(
  'python-decorator'
  'python-jedi'
  'python-matplotlib-inline'
  'python-pexpect'
  'python-prompt_toolkit'
  'python-pygments'
  'python-stack-data'
  'python-traitlets'
  'sqlite'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=(
  'jupyter-nbformat'
  'python-curio'
  'python-ipykernel'
  'python-matplotlib'
  'python-numpy'
  'python-pandas'
  'python-pickleshare'
  'python-pytest'
  'python-pytest-asyncio'
  'python-testpath'
  'python-trio'
  'tcsh'
  'texlive-bin'
  'texlive-latex'
)
optdepends=(
  'python-black: to auto format with Black'
  'python-pickleshare: for the ip.db database'
  'yapf: to auto format with YAPF'
)
source=(
  "git+https://github.com/ipython/ipython.git#tag=$pkgver?signed"
  'IPython-icon.png::https://www.packal.org/sites/default/files/public/styles/icon_large/public/workflow-files/nkeimipynbworkflow/icon/icon.png'
)
b2sums=('SKIP'
        'd445e2bc7a037db8715ea103611720e965987e155c32e445b0ef783e519fca8a0301b16c5763fd9a5d8d169c3b0d7b4db6c0bd0f9772842258b135dcb1d6d5a2')
validpgpkeys=('99B17F64FD5C94692E9EF8064968B2CC0208DCC8') # Matthias Bussonnier <bussonniermatthias@gmail.com>

build() {
  cd $pkgname
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd $pkgname
  PYTHONPATH="$PWD/$pkgname:$PYTHONPATH" pytest
}

package() {
  # FS#47046
  install -Dm644 IPython-icon.png "$pkgdir"/usr/share/pixmaps/ipython.png

  cd $pkgname
  python -m installer --destdir="$pkgdir" dist/*.whl

  cd 'examples/IPython Kernel'
  # FS#45120
  sed -i 's/gnome-netstatus-idle/ipython/' ipython.desktop
  install -Dm644 -t "$pkgdir"/usr/share/applications ipython.desktop

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/$pkgname-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
